﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using System.Data.SqlClient;
//using GBFinance.Entity;
//using HiLand.Utility.DataBase;
//using HiLand.Utility.Paging;
//using System.Data;
//using HiLand.Utility.Finance;

//namespace GBFinance.DAL
//{
//    public class LoanBasicInfoDAL
//    {
//        public virtual bool Create(LoanBasicInfoEntity entity)
//        {
//            string commandText = @"Insert Into [LoanBasicInfo] (
//			        [LoanGuid],
//			        [LoanType],
//			        [LoanAmount],
//			        [LoanTermType],
//			        [LoanInterest],
//			        [LoanTermCount],
//			        [LoanPurpose],
//			        [LoanUserID],
//			        [LoanDate],
//			        [LoanStatus],
//			        [CheckUserID],
//			        [CheckDate],
//			        [PropertyNames],
//			        [PropertyValues]
//                ) 
//                Values (
//			        @LoanGuid,
//			        @LoanType,
//			        @LoanAmount,
//			        @LoanTermType,
//			        @LoanInterest,
//			        @LoanTermCount,
//			        @LoanPurpose,
//			        @LoanUserID,
//			        @LoanDate,
//			        @LoanStatus,
//			        @CheckUserID,
//			        @CheckDate,
//			        @PropertyNames,
//			        @PropertyValues
//                )";

//            SqlParameter[] sqlParas = PrepareParasAll(entity);

//            bool isSuccessful = SqlHelperEx.ExecuteSingleRowNonQuery(commandText, sqlParas);
//            return isSuccessful;
//        }

//        public virtual bool Update(LoanBasicInfoEntity entity)
//        {
//            string commandText = @"Update [LoanBasicInfo] Set   
//					[LoanGuid] = @LoanGuid,
//					[LoanType] = @LoanType,
//					[LoanAmount] = @LoanAmount,
//					[LoanTermType] = @LoanTermType,
//					[LoanInterest] = @LoanInterest,
//					[LoanTermCount] = @LoanTermCount,
//					[LoanPurpose] = @LoanPurpose,
//					[LoanUserID] = @LoanUserID,
//					[LoanDate] = @LoanDate,
//					[LoanStatus] = @LoanStatus,
//					[CheckUserID] = @CheckUserID,
//					[CheckDate] = @CheckDate,
//					[PropertyNames] = @PropertyNames,
//					[PropertyValues] = @PropertyValues
//             Where [LoanGuid] = @LoanGuid";

//            SqlParameter[] sqlParas = PrepareParasAll(entity);

//            bool isSuccessful = SqlHelperEx.ExecuteSingleRowNonQuery(commandText, sqlParas);
//            return isSuccessful;
//        }

//        public virtual bool Delete(LoanBasicInfoEntity entity)
//        {
//            string commandText = @"Delete From [LoanBasicInfo] Where [LoanGuid] = @LoanGuid";

//            SqlParameter[] sqlParas = PrepareParasAll(entity);

//            bool isSuccessful = SqlHelperEx.ExecuteSingleRowNonQuery(commandText, sqlParas);
//            return isSuccessful;
//        }

//        public virtual LoanBasicInfoEntity Get(Guid LoanGuid)
//        {
//            string commandText = "SELECT * FROM [LoanBasicInfo] WHERE  [LoanGuid] = @LoanGuid";
//            SqlParameter[] sqlParas = new SqlParameter[] { new SqlParameter("@LoanGuid", LoanGuid) };
//            return SqlGeneral.GetEntity<LoanBasicInfoEntity>(commandText, sqlParas, Load);
//        }

//        /// <summary>
//        /// 获取新闻类别列表
//        /// </summary>
//        /// <param name="onlyDisplayUsable"></param>
//        /// <param name="whereClause"></param>
//        /// <returns></returns>
//        public virtual List<LoanBasicInfoEntity> GetList(string whereClause)
//        {
//            List<LoanBasicInfoEntity> collection = new List<LoanBasicInfoEntity>();
//            List<SqlParameter> sqlparaList = new List<SqlParameter>();
//            if (string.IsNullOrEmpty(whereClause))
//            {
//                whereClause = " 1=1 ";
//            }

//            //if (onlyDisplayUsable == Logics.True)
//            //{
//            //    whereClause += " AND [CanUsable]= @CanUsable ";
//            //    sqlparaList.Add(new SqlParameter("@CanUsable", (int)onlyDisplayUsable));
//            //}

//            string commandText = "SELECT * FROM [LoanBasicInfo] WHERE  " + whereClause;
//            SqlParameter[] sqlParas = sqlparaList.ToArray();
//            collection = SqlGeneral.GetEntityList<LoanBasicInfoEntity>(commandText, sqlParas, Load);

//            return collection;
//        }

//        public virtual PagedEntityCollection<LoanBasicInfoEntity> GetPagedCollection(int startIndex, int pageSize, string whereClause, string orderClause)
//        {
//            return SqlGeneral.GetPagedCollection<LoanBasicInfoEntity>("usp_Loan_BasicInfo_SelectPaging", whereClause, orderClause, startIndex, pageSize, Load);
//        }


//        /// <summary>
//        /// 获取总的条目
//        /// </summary>
//        /// <param name="whereClause"></param>
//        /// <returns></returns>
//        public virtual int GetTotalCount(string whereClause)
//        {
//            return SqlGeneral.GetTotalCount("LoanBasicInfo", whereClause);
//        }

//        #region 辅助方法
//        private static SqlParameter[] PrepareParasAll(LoanBasicInfoEntity entity)
//        {
//            List<SqlParameter> list = new List<SqlParameter>() 
//            {
//                new SqlParameter("@LoanGuid",entity.LoanGuid),
//                new SqlParameter("@LoanType",(int)entity.LoanType),
//                new SqlParameter("@LoanAmount",entity.LoanAmount),
//                new SqlParameter("@LoanTermType",(int)entity.LoanTermType),
//                new SqlParameter("@LoanInterest",entity.LoanInterest),
//                new SqlParameter("@LoanTermCount",entity.LoanTermCount),
//                new SqlParameter("@LoanPurpose",entity.LoanPurpose??string.Empty),
//                new SqlParameter("@LoanUserID",entity.LoanUserID),
//                new SqlParameter("@LoanDate",entity.LoanDate),
//                new SqlParameter("@LoanStatus",(int)entity.LoanStatus),
//                new SqlParameter("@CheckUserID",entity.CheckUserID),
//                new SqlParameter("@CheckDate",entity.CheckDate),
//                new SqlParameter("@PropertyNames",entity.PropertyNames??string.Empty),
//                new SqlParameter("@PropertyValues",entity.PropertyValues??string.Empty)
//            };

//            return list.ToArray();
//        }

//        public static LoanBasicInfoEntity Load(IDataReader reader)
//        {
//            LoanBasicInfoEntity entity = new LoanBasicInfoEntity();
//            if (reader != null && reader.IsClosed == false)
//            {
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "LoanID"))
//                {
//                    entity.LoanID = reader.GetInt32(reader.GetOrdinal("LoanID"));
//                }
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "LoanGuid"))
//                {
//                    entity.LoanGuid = reader.GetGuid(reader.GetOrdinal("LoanGuid"));
//                }
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "LoanType"))
//                {
//                    entity.LoanType = (LoanTypes)reader.GetInt32(reader.GetOrdinal("LoanType"));
//                }
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "LoanAmount"))
//                {
//                    entity.LoanAmount = reader.GetDecimal(reader.GetOrdinal("LoanAmount"));
//                }
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "LoanTermType"))
//                {
//                    entity.LoanTermType = (PaymentTermType)reader.GetInt32(reader.GetOrdinal("LoanTermType"));
//                }
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "LoanInterest"))
//                {
//                    entity.LoanInterest = reader.GetDecimal(reader.GetOrdinal("LoanInterest"));
//                }
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "LoanTermCount"))
//                {
//                    entity.LoanTermCount = reader.GetInt32(reader.GetOrdinal("LoanTermCount"));
//                }
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "LoanPurpose"))
//                {
//                    entity.LoanPurpose = reader.GetString(reader.GetOrdinal("LoanPurpose"));
//                }
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "LoanUserID"))
//                {
//                    entity.LoanUserID = reader.GetGuid(reader.GetOrdinal("LoanUserID"));
//                }
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "LoanDate"))
//                {
//                    entity.LoanDate = reader.GetDateTime(reader.GetOrdinal("LoanDate"));
//                }
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "LoanStatus"))
//                {
//                    entity.LoanStatus = (LoanStatuses)reader.GetInt32(reader.GetOrdinal("LoanStatus"));
//                }
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CheckUserID"))
//                {
//                    entity.CheckUserID = reader.GetGuid(reader.GetOrdinal("CheckUserID"));
//                }
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CheckDate"))
//                {
//                    entity.CheckDate = reader.GetDateTime(reader.GetOrdinal("CheckDate"));
//                }

//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "LoanUserName"))
//                {
//                    entity.LoanUserName = reader.GetString(reader.GetOrdinal("LoanUserName"));
//                }

//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "PropertyNames"))
//                {
//                    entity.PropertyNames = reader.GetString(reader.GetOrdinal("PropertyNames"));
//                }
//                if (DataReaderHelper.IsExistFieldAndNotNull(reader, "PropertyValues"))
//                {
//                    entity.PropertyValues = reader.GetString(reader.GetOrdinal("PropertyValues"));
//                }
//            }
//            return entity;
//        }
//        #endregion
//    }
//}
